//
//  SEGServiceHotlineManager.m
//  Commom
//
//  Created by 乔杨 on 2019/5/6.
//

#import "SEGServiceHotlineManager.h"
 
#if __has_include(<Common/SEGProfileManager.h>)
#import <Commom/SEGProfileManager.h>
#else
#import "SEGProfileManager.h"
#endif
#if __has_include(<Common/SEGModel.h>)
#import <Common/SEGModel.h>
#else
#import "SEGModel.h"
#endif

@implementation SEGServiceHotlineManager

- (void)hotline_selectStewardPhoneWithFinished:(SEGNetworkReponse)finished {
    NSString *houseId = [SEGProfileManager sharedManager].profile.houseId;
    NSDictionary *params = @{@"houseId":houseId,
                             @"communityId":kAccountCommunityID};
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL, @"/bms-api/v1/customer/selectStewardPhone",nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:GET URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (!isSuccessed || result == nil) {
            finished(NO, nil, codeType, errorMessage);
            return;
        }
        if (![result isKindOfClass:[NSDictionary class]]) {
            finished(NO, nil, codeType, errorMessage);
            return;
        }
        NSDictionary *dataDic = result[@"data"];
        [self.dataSourceArr removeAllObjects];
        for (NSDictionary *dic in dataDic[@"list"]) {
            SEGServiceHotlineModel *model = [SEGServiceHotlineModel yy_modelWithDictionary:dic];
            [self.dataSourceArr addObject:model];
        }
        finished(isSuccessed, result, codeType, errorMessage);
    }];
}

/**
 获取物业客服电话热线
 
 @param finished 回调
 */
- (void)getServiceHotLineWithFinished:(SEGNetworkReponse)finished {
    NSDictionary *params = @{@"communityId":kAccountCommunityID};
    NSString *urlString = [SEGServerManager serverUrlJoint:kClientRootURL,@"/basic-data-api/rest-api/v1/organApi/getServiceTel/",kAccountCommunityID,nil];
    [SEGHTTPBusinessManager seg_requestWithMethod:POST URLString:urlString parameters:params finished:^(BOOL isSuccessed, id result, NSString *codeType, NSString *errorMessage) {
        if (!isSuccessed || result == nil) {
            finished(NO, nil, codeType, errorMessage);
            return;
        }
        if (![result isKindOfClass:[NSDictionary class]]) {
            finished(NO, nil, codeType, errorMessage);
            return;
        }
        finished(isSuccessed, result, codeType, errorMessage);
    }];
}

#pragma mark - Getter
- (NSMutableArray<SEGServiceHotlineModel *> *)dataSourceArr {
    if (!_dataSourceArr) {
        _dataSourceArr = [NSMutableArray array];
    }
    return _dataSourceArr;
}


@end
